<?php

namespace App\Http\Requests\client;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait CommonPriceRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'tidan_price' => 'required|numeric',
            'fendan_price' => 'required|numeric',
        ], [
            'tidan_price.required' => '请填写提单费单价',
            'tidan_price.numeric' => '提单费必须是数值类型',
            'fendan_price.required' => '请填写分单费单价',
            'fendan_price.numeric' => '分单费必须是数值类型',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
